﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
using HotelManagement._02.BUS;

namespace CSDL_QuanLyBanHang._01.FORM
{
    public partial class F02_Report : Form
    {
        public F02_Report()
        {
            InitializeComponent();
            Init();

        }
        private void Init()
        {  
            m_cbb_Report.Items.Add("Thống kê đặt phòng theo nhân viên thực hiện");                        //id=0
            m_cbb_Report.Items.Add("Thống kê đặt phòng theo khách hàng");   //id=1
            m_cbb_Report.Items.Add("Thống kê phòng được đặt");                            //id=2
            m_cbb_Report.Items.Add("Thống kê phòng bị đổi hoặc hủy");            //id=3
            m_cbb_Report.Items.Add("Thống kê thông tin khách hàng");             //id=4
            m_cbb_Report.Items.Add("Thống kê thanh toán theo khách hàng");                       //id=5
            m_cbb_Report.Items.Add("Thống kê dịch vụ theo khách hàng");      //id=6
            m_cbb_Report.Items.Add("Thống kê dịch vụ");                          //id=7
        }
        public void Show(DataTable ip_Dt, string ip_Path, ParameterFields ip_ParameterFields)
        {
            try
            {
                ReportDocument v_Report = new ReportDocument();
                string v_Path = Application.StartupPath;
                v_Path = v_Path.Substring(0,v_Path.Length - 10);
                v_Report.Load(v_Path + @"\05.REPORT\" + ip_Path);
                v_Report.SetDataSource(ip_Dt);
                m_rpt_Report.ParameterFieldInfo = ip_ParameterFields;
                m_rpt_Report.ReportSource = v_Report;
                this.Show();
            }
            catch (Exception v_e)
            {

                MessageBox.Show(v_e.Message);
            }

        }

        private void frm00_MauBaoCaoThongKe_Load(object sender, EventArgs e)
        {

            
        }

        private void report_Click(object sender, EventArgs e)
        {
            if (m_cbb_Report.SelectedIndex==-1)
            {
                MessageBox.Show("Chưa chọn nội dung báo cáo");
            }
            if (m_cbb_Report.SelectedIndex == 0)
            {
                ReportBookingInfoBUS v_ReportBookingInfoBUS = new ReportBookingInfoBUS();
                DataTable v_Dt = new DataTable();
                v_Dt = v_ReportBookingInfoBUS.ViewReportBookingInfo(m_dt_FromDate.Value, m_dt_ToDate.Value);
                ParameterFields v_ParameterFields = new ParameterFields();
                //v_ParameterFields = v_ReportCustomerServiceBUS.AddParameter(m_dt_FromDate.Value, m_dt_ToDate.Value);
                this.Show(v_Dt, "R01_BookingInfo.rpt", v_ParameterFields);
            }
            if (m_cbb_Report.SelectedIndex == 2)
            {
                ReportRoomCheckInInfoBUS v_ReportRoomCheckInInfoBUS = new ReportRoomCheckInInfoBUS();
                DataTable v_Dt = new DataTable();
                v_Dt = v_ReportRoomCheckInInfoBUS.ViewCheckInRoomInfo(m_dt_FromDate.Value, m_dt_ToDate.Value);
                ParameterFields v_ParameterFields = new ParameterFields();
                //v_ParameterFields = v_ReportCustomerServiceBUS.AddParameter(m_dt_FromDate.Value, m_dt_ToDate.Value);
                this.Show(v_Dt, "R02_RoomCheckInInfo.rpt", v_ParameterFields);
            }
            if (m_cbb_Report.SelectedIndex == 7)
            {
                ReportServiceInfoBUS v_ReportServiceInfoBUS = new ReportServiceInfoBUS();
                DataTable v_Dt = new DataTable();
                v_Dt = v_ReportServiceInfoBUS.ViewReportServiceInfo(m_dt_FromDate.Value, m_dt_ToDate.Value);
                ParameterFields v_ParameterFields = new ParameterFields();
                this.Show(v_Dt, "R03_ServiceInfo.rpt", v_ParameterFields);
                // this.Dispose();
            }
            if (m_cbb_Report.SelectedIndex == 3)
            {
                ReportChangeCancelRoomBUS v_ReportChangeCancelRoomBUS = new ReportChangeCancelRoomBUS();
                DataTable v_Dt = new DataTable();
                v_Dt = v_ReportChangeCancelRoomBUS.ViewReportChangeCancelRoom(m_dt_FromDate.Value, m_dt_ToDate.Value);
                ParameterFields v_ParameterFields = new ParameterFields();
                this.Show(v_Dt, "R04_ChangeCancelRoom.rpt", v_ParameterFields);
                // this.Dispose();
            }
            if (m_cbb_Report.SelectedIndex == 4)
            {
                ReportCustomerInfoBUS v_ReportCustomerInfoBUS = new ReportCustomerInfoBUS();
                DataTable v_Dt = new DataTable();
                v_Dt = v_ReportCustomerInfoBUS.ViewReportCustomerInfo();
                ParameterFields v_ParameterFields = new ParameterFields();
                this.Show(v_Dt, "R05_CustomerInfo.rpt", v_ParameterFields);
               // this.Dispose();
            }
            if (m_cbb_Report.SelectedIndex == 5)
            {
                ReportTotalCostBUS v_ReportTotalCostBUS = new ReportTotalCostBUS();
                DataTable v_Dt = new DataTable();
                v_Dt = v_ReportTotalCostBUS.ViewReportTotalCost(m_dt_FromDate.Value, m_dt_ToDate.Value);
                ParameterFields v_ParameterFields = new ParameterFields();
                this.Show(v_Dt, "R06_TotalCost.rpt", v_ParameterFields);
                //this.Dispose();
            }
            if (m_cbb_Report.SelectedIndex == 1)
            {
                ReportCustomerRentCostBUS v_ReportCustomerRentCostBUS = new ReportCustomerRentCostBUS();
                DataTable v_Dt = new DataTable();
                v_Dt = v_ReportCustomerRentCostBUS.ViewReportCustomerRentCost(m_dt_FromDate.Value, m_dt_ToDate.Value);
                ParameterFields v_ParameterFields = new ParameterFields();
                this.Show(v_Dt, "R07_CustomerRentCost.rpt", v_ParameterFields);
                //this.Dispose();
            }
            if (m_cbb_Report.SelectedIndex == 6)
            {
                ReportCustomerServiceBUS v_ReportCustomerServiceBUS = new ReportCustomerServiceBUS();
                DataTable v_Dt = new DataTable();
                v_Dt = v_ReportCustomerServiceBUS.ViewReportCustomerService(m_dt_FromDate.Value,m_dt_ToDate.Value);
                ParameterFields v_ParameterFields = new ParameterFields();
                v_ParameterFields = v_ReportCustomerServiceBUS.AddParameter(m_dt_FromDate.Value, m_dt_ToDate.Value);
                this.Show(v_Dt, "R08_CustomerService.rpt", v_ParameterFields);
                //this.Dispose();
            }
        }
    }
}
